﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WISD.CarFriend.Model;
using WISD.Common;

namespace WISD.CarFriend.BLL.Web
{
  public  static  class TypeManageModule
    {
      /// <summary>
      /// 获取所有的类别
      /// </summary>
      /// <returns></returns>
      public static List<T_CF_Web_Type> GetAllType()
      {
          List<T_CF_Web_Type> alltype = new List<T_CF_Web_Type>();
          using (CarFriendDBContext db = new CarFriendDBContext())
          {
              alltype = db.T_CF_Web_Type.Where(p => p.State == 1).ToList();
          }
          return alltype;
      }


      /// <summary>
      /// 根据类别ID获取类别名称
      /// </summary>
      /// <param name="id"></param>
      /// <returns></returns>
      public static string GetTypeNameByID(int id)
      {
          string TypeName = string.Empty;
          using (CarFriendDBContext db = new CarFriendDBContext())
          {
              var type = db.T_CF_Web_Type.FirstOrDefault(p => p.State == 1&&p.TypeID==id);
              TypeName = type == null ? "" : type.TypeName;          
          }
          return TypeName;
      }

    }
}
